//*************************************************************************************
//* 作    者： zouhunter
//* 创建时间： 2021-10-08 02:39:26
//* 描    述： 

//* ************************************************************************************
using System;
using UnityEngine;
using UnityEngine.UI;

public class InfoNoticeBehaviour : MonoBehaviour
{
    protected const float DISTENCE_SCALE = 1.02f;//距离参数
    protected Vector3 m_startScale;
    public Text m_title;

    void Awake()
    {
        m_startScale = transform.localScale;
    }

    public void SetText(string text)
    {
        m_title.text = text;
    }

    public void SetPosition(Vector3 targetPos,float offset)
    {
        var startPos = Camera.main.transform.position;
        var direction = (targetPos - startPos);
        var pos = targetPos - direction.normalized * offset;
        transform.position = pos;
        transform.forward = direction;
        transform.localScale = m_startScale * direction.magnitude * DISTENCE_SCALE;
    }
}
